package cn.lyd.base.enm;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

@Getter
@AllArgsConstructor
public enum PetStateEnum {
    //宠物状态：0下架，1上架
    ONSALE(1,"上架"),
    OFFSALE(0,"下架");


    public static String getNameByCode(Integer code){
        Optional<PetStateEnum> first = Arrays.stream(PetStateEnum.values()).filter(state -> state.getCode() == code)
                .findFirst();
        return first.isPresent()?first.get().getName():"";
    }

    private int code;

    private String name;
}
